package com.eling.elcms.travel.model;

import com.eling.elcms.basedoc.model.EnumSerializer;
import com.eling.elcms.core.dao.annotation.Between;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancer;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancers;
import com.eling.elcms.core.dao.annotation.In;
import com.eling.elcms.core.dao.hibernate.OrderCriteriaEnhancer;
import com.eling.elcms.core.dao.hibernate.search.EnumBridge;
import com.eling.elcms.core.model.BaseModel;
import com.eling.elcms.system.model.CommonUser;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.hibernate.search.annotations.*;

import javax.persistence.*;
import java.util.Date;

/**
 * 合同签约退费单
 * @author linjizeng
 *
 * 
 */
@Entity
@Table(name = "travel_contractrefund")
@Indexed
@CriteriaEnhancers(criteriaEnhancers = {
		@CriteriaEnhancer(impl = OrderCriteriaEnhancer.class)})
public class TravelContractRefund extends BaseModel{

	private static final long serialVersionUID = -4293726892214175916L;
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@DocumentId
	@In
	private Long pkTravelContractRefund;
	
	/** 合同签约*/
	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pkTravelContract")
	@IndexedEmbedded(depth = 1)
	private TravelContract travelContract;
	
	/** 实退(元)*/
	@Column
	@Field
	private Double price;
	
	/** 退费日期 */
	@Column
	@Field
	@Between
	private Date refundDate;
	
	/** 经办人 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "operator")
	@IndexedEmbedded(depth = 1)
	private CommonUser operator;
	
	/** 退费状态*/
	@Enumerated(EnumType.STRING)
	@In	
	@FieldBridge(impl = EnumBridge.class)
	private RefundStatus status;
	
	@JsonSerialize(using = EnumSerializer.class)
	public static enum RefundStatus {
		Refund("已退费"),NoRefund("待退费");
		private String display;
		RefundStatus(String display) {
			this.display = display;
		}
		public String getDisplay() {
			return display;
		}
	}

	@Version
	private Integer version;

	public Long getPkTravelContractRefund() {
		return pkTravelContractRefund;
	}

	public void setPkTravelContractRefund(Long pkTravelContractRefund) {
		this.pkTravelContractRefund = pkTravelContractRefund;
	}

	public TravelContract getTravelContract() {
		return travelContract;
	}

	public void setTravelContract(TravelContract travelContract) {
		this.travelContract = travelContract;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public Date getRefundDate() {
		return refundDate;
	}

	public void setRefundDate(Date refundDate) {
		this.refundDate = refundDate;
	}

	public CommonUser getOperator() {
		return operator;
	}

	public void setOperator(CommonUser operator) {
		this.operator = operator;
	}

	public RefundStatus getStatus() {
		return status;
	}

	public void setStatus(RefundStatus status) {
		this.status = status;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}
	
}
